<?php
//require_once ('dompdf/dompdf_config.inc.php');
class User_DompdfController extends Model3_Controller
{
    public function init()
    {
        /*No incluir ningun archivo de css ya que hace que el pdf deje de funcionar*/
    }
    
    public function indexAction()
    {
        $this->view->setUseTemplate(false);
        $idOrder = $this->getRequest()->getParam('id');
        $this->view->order = $idOrder;
        
        $dbs = Model3_Registry::getInstance()->get('databases');
        $em = $dbs['DefaultDb'];
        $ordersAdapter = $em->getRepository('DefaultDb_Entities_M3CommerceOrder');
        $packagesAdapter = $em->getRepository('DefaultDb_Entities_PackageToOrder');
        $sequentialAdapter = $em->getRepository('DefaultDb_Entities_SequentialActivities');
        $routsAdapter = $em->getRepository('DefaultDb_Entities_RoutePoint');
        
        $order = $ordersAdapter->find($idOrder);
        $packs = $packagesAdapter->findBy(array('order'=>$order));
        $rout = $routsAdapter->findBy(array('point'=>$order->getPointBuyer()));
        $sequentials = $sequentialAdapter->findBy(array('order'=>$order),array('shippingDate' => 'asc'));
        
        $this->view->rout = $rout;
        $this->view->order = $order;
        $this->view->packs = $packs;
        $this->view->sequentials = $sequentials;
    }
}